package com.hengxinguotong.hxgtwygsp.ui.member;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.hengxinguotong.hxgtwygsp.R;
import com.hengxinguotong.hxgtwygsp.model.Member;
import com.hengxinguotong.hxgtwygsp.ui.base.BaseDialogActivity;
import com.hengxinguotong.hxgtwygsp.widget.RecycleViewDivider;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * TODO 成员信息
 *
 * @author hjz
 * @version V1.0.0
 * @since 2019/4/3 9:27
 */
public class MemberActivity extends BaseDialogActivity implements MemberContract.IView {
    @Inject
    MemberContract.IPresenter mPresenter;
    @BindView(R.id.member_recycler)
    RecyclerView memberRecycler;

    private List<Member> memberList = new ArrayList<>();;
    private MemberAdapter mAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mPresenter.bindView(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mPresenter.dropView();
    }

    @Override
    public int getLayoutResId() {
        return R.layout.activity_member;
    }

    @Override
    public void init() {
        mockView();

        LinearLayoutManager llm = new LinearLayoutManager(this);
        llm.setOrientation(LinearLayoutManager.VERTICAL);
        memberRecycler.setLayoutManager(llm);
        memberRecycler.addItemDecoration(new RecycleViewDivider(this).color(R.color.c0555AC));
        mAdapter = new MemberAdapter(R.layout.item_member,memberList);
        memberRecycler.setAdapter(mAdapter);
    }

    private void mockView() {
        memberList.add(new Member(R.mipmap.member_picture,"朱文泽","男",41,"高中","1-1-204","武汉华康酒业有限公司","委员","13385282058"));
        memberList.add(new Member(R.mipmap.member_picture,"廖安军","男",43,"本科","3-2-1701","武汉明辉医药公司","主任","13098862116"));
        memberList.add(new Member(R.mipmap.member_picture,"何智刚","男",38,"本科","6-3-203","唐家墩派出所","工程监督委员","13396069609"));
        memberList.add(new Member(R.mipmap.member_picture,"曾国华","男",37,"研究生","4-1-601","湖北移动","安防环境监督委员","13871586699"));
        memberList.add(new Member(R.mipmap.member_picture,"苏良雄","男",28,"本科","2-1-3102","武汉金色大地策划有限公司","总务委员","15527939469"));
        memberList.add(new Member(R.mipmap.member_picture,"胡丽丽","女",40,"高中","5A-2101","自由职业","维护权益宣传委员","13986085025"));
    }

    @OnClick(R.id.member_close)
    public void onViewClicked() {
        finish();
    }

}
